package com.junzhiit.nengji.shop.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.bainaeco.framework.util.AssertUtil;
import com.junzhiit.nengji.shop.service.UserEvaluateService;
import com.junzhiit.nengji.shop.web.vo.ResultVO;
import com.junzhiit.nengji.shop.web.vo.UserEvaluateAddVO;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/user/evaluate")
public class UserEvaluateController extends BaseController {

	@Autowired
	private UserEvaluateService userEvaluateService;
	
	@ApiOperation(value = "查询商品的用户评价")
	@RequestMapping(value = "/goods", method = RequestMethod.GET)
	public ResultVO findUserEvaluate(Integer pageNumber,Integer maxPageRow,String goodsId,Integer status,String evaluateTagId) {
		AssertUtil.notNull(pageNumber, "pageNumber is required.");
		AssertUtil.notNull(maxPageRow, "maxPageRow is required.");
		AssertUtil.notBlank(goodsId, "goodsId is required.");
		AssertUtil.notNull(status, "status is required.");
		return userEvaluateService.findUserEvaluate(pageNumber,maxPageRow,goodsId,status,evaluateTagId);
	}
	
	@ApiOperation(value = "新增用户评价")
	@RequestMapping(method = RequestMethod.POST)
	public ResultVO add(UserEvaluateAddVO userEvaluateAddVO) {
		AssertUtil.notBlank(userEvaluateAddVO.getUserId(), "userId is required.");
		AssertUtil.notBlank(userEvaluateAddVO.getGoodsId(), "goodsId is required.");
		AssertUtil.notBlank(userEvaluateAddVO.getOrdersGoodsId(), "ordersGoodsId is required.");
		AssertUtil.notBlank(userEvaluateAddVO.getShopId(), "shopId is required.");
		AssertUtil.notNull(userEvaluateAddVO.getScore(), "score is required.");
		AssertUtil.notNull(userEvaluateAddVO.getContent(), "content is required.");
		AssertUtil.notNull(userEvaluateAddVO.getIsAnonymity(),"isAnonymity is required.");
		return userEvaluateService.add(userEvaluateAddVO);
	}
}
